package net.chenlin.dp.modules.business.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.chenlin.dp.common.entity.R;
import net.chenlin.dp.modules.business.service.DataImportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;


/**
 * @author Yangsm
 * @ClassName: DataImportController
 * @Description: TODO
 * @date 2022年10月26日 11:05
 */
@RestController
@RequestMapping("/import")
@Api(tags = "数据导入")
public class DataImportController {

    @Autowired
    private DataImportService dataImportService;


//    @Transactional
//    @ApiOperation(value = "导入")
//    @PostMapping("/excel")
//    public R excelWarehousing(MultipartFile file, HttpServletRequest request) {
//        //批量导入案例
//        dataImportService.saveSubject(file, dataImportService);
//        return R.ok("导入成功");
//    }


//    @Transactional
//    @ApiOperation(value = "电能-导入")
//    @PostMapping("/electricExcel")
//    public R electricExcel(MultipartFile file) {
//        //批量导入案例
//        dataImportService.electricExcel(file);
//        return R.ok("导入成功");
//    }

    @Transactional
    @ApiOperation(value = "户表数据excel文件导入 -- (在用)")
    @PostMapping("/deviceExcel")
    public R deviceExcel(MultipartFile file) {
        //批量导入案例
        dataImportService.deviceExcel(file);
        return R.ok("导入成功");
    }

    @Transactional
    @ApiOperation(value = "导入设备校准信息数据 -- (在用)")
    @PostMapping("/importDeviceCalibration")
    public R importDeviceCalibration(MultipartFile file) throws IOException {
        //批量导入案例
        dataImportService.importDeviceCalibration(file);
        return R.ok("导入成功");
    }


}
